package com.ruiyian.bridge.task;

import com.ruiyian.bridge.info.service.DialyReportService;
import com.ruiyian.bridge.info.service.SensorWarningLogService;
import com.ruiyian.bridge.project.domain.DeviceWarnSet;
import com.ruiyian.bridge.project.domain.MeasurePoint;
import com.ruiyian.bridge.project.service.DeviceWarnSetService;
import com.ruiyian.bridge.project.service.MeasurePointfoService;
import com.ruiyian.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @author chong
 * @email 673426164@qq.com
 * @create 2022/6/24
 * Desc: 桥梁定时任务
 */
@Slf4j
@Component("bridgeTask")
public class BridgeTask {
    @Autowired
    private SensorWarningLogService sensorWarningLogService;
    @Autowired
    private MeasurePointfoService measurePointfoService;
    @Autowired
    private DialyReportService dialyReportService;

    /**
     * 定时生成 数据同步
     */
    public void dataSync() {
        log.info("执行定时生成 数据同步");
        // 本地  激光
        measurePointfoService.dataSyncAll();
    }

    /**
     * 添加超限预警
     */
    public void checkWarning(){
        try {
            log.info("添加超限预警");
            sensorWarningLogService.addWarnLog();
        }catch (Exception e){
            log.error("添加超限预警异常"+e.getMessage());
        }
    }

    /**
     * 生成日报
     */
    public void createDialy() {
        log.info("执行定时生成日报");
        try {
            dialyReportService.creatDoc();
        } catch (Exception e) {
            log.error("执行定时生成日报异常"+e.getMessage());
        }
    }
}
